#!/bin/bash
read -p "请输入IP地址：" ip
ping -w1 $ip &>/dev/null
#需要安装配置mail服务
yum -y install mailx&>/dev/null
if [ $? -eq 0 ]
then
    echo "$ip is ok"|mailx -s "check localhost" IG1303407920@163.com
else
    echo "$ip is down"|mailx -s "check localhost" IG1303407920@163.com
fi